import csv
from matplotlib import pyplot as plt
from datetime import datetime

filename = 'weather_data/death_valley_2021_simple.csv'
hights, lows, daets = [], [], []

with open(filename) as f:
    reader = csv.reader(f)
    header_row = next(reader)
    print(header_row)
    for row in reader:
        high = row[-3]
        low = row[-2]
        current_date = datetime.strptime(row[2], "%Y-%m-%d")
        if high == '':
            high = 0
        else:
            high = int(high)

        if low == '':
            low = 0
        else:
            low = int(low)
        hights.append(high)
        lows.append(low)
        daets.append(current_date)

# print('hights', hights)

fig = plt.figure(dpi=128, figsize=(10,6))
plt.plot(daets, hights, c='red')
plt.plot(daets, lows, c='blue')
plt.fill_between(daets, hights, lows, facecolor='blue', alpha=0.1)

plt.title('High temperatures')
plt.xlabel('', fontsize=16)
plt.ylabel('Temperature(F)', fontsize=16)
fig.autofmt_xdate()
plt.tick_params(axis='both', which='major', labelsize=16)

plt.show()
